package com.qs.questionnairesurveysystem.service.impl;

import com.qs.questionnairesurveysystem.entity.Question;
import com.qs.questionnairesurveysystem.mapper.QuestionMapper;
import com.qs.questionnairesurveysystem.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    private QuestionMapper questionMapper;

    // 创建新问题
    @Override
    public void createQuestion(Question question) {
        questionMapper.insertQuestion(question);
    }

    // 更新问题
    @Override
    public void updateQuestion(Question question) {
        questionMapper.updateQuestion(question);
    }

    // 删除问题
    @Override
    public void deleteQuestion(Long questionId) {
        questionMapper.deleteQuestion(questionId);
    }

    // 获取指定问题
    @Override
    public Question getQuestionById(Long questionId) {
        return questionMapper.getQuestionById(questionId);
    }

    // 获取所有问题
    @Override
    public List<Question> getAllQuestions() {
        return questionMapper.getAllQuestions();
    }

    // 根据问卷ID获取问题
    @Override
    public List<Question> getQuestionsBySurveyId(Long surveyId) {
        return questionMapper.getQuestionsBySurveyId(surveyId);
    }
}
